<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Class: InstreamAdapter</title>

    <script src="scripts/prettify/prettify.js"> </script>
    <script src="scripts/prettify/lang-css.js"> </script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">

    <h1 class="page-title">Class: InstreamAdapter</h1>

    




<section>

<header>
    
        <h2><span class="attribs"><span class="type-signature"></span></span>InstreamAdapter<span class="signature">(_controller, _model, _view, _mediaPool)</span><span class="type-signature"></span></h2>
        
    
</header>

<article>
    <div class="container-overview">
    
        

    

    
    <h4 class="name" id="InstreamAdapter"><span class="type-signature"></span>new InstreamAdapter<span class="signature">(_controller, _model, _view, _mediaPool)</span><span class="type-signature"></span></h4>
    

    



<div class="description">
    <p>InstreamAdapter JW Player instream API. Instantiated via jwplayer().createInstream(). Only one instance can be
created per player. It is destroyed via jwplayer().instreamDestroy().</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>_controller</code></td>
            

            <td class="type">
            
                
<span class="param-type">Controller</span>


            
            </td>

            

            

            <td class="description last"><p>The player controller instance</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>_model</code></td>
            

            <td class="type">
            
                
<span class="param-type">Model</span>


            
            </td>

            

            

            <td class="description last"><p>The player model instance</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>_view</code></td>
            

            <td class="type">
            
                
<span class="param-type">View</span>


            
            </td>

            

            

            <td class="description last"><p>The player view instance</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>_mediaPool</code></td>
            

            <td class="type">
            
                
<span class="param-type">MediaPool</span>


            
            </td>

            

            

            <td class="description last"><p>The player media pool</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>


















    
    </div>

    

    

    

    

    

    

    

    
        <h3 class="subsection-title">Methods</h3>

        
            

    

    
    <h4 class="name" id="applyProviderListeners"><span class="type-signature"></span>applyProviderListeners<span class="signature">(provider)</span><span class="type-signature"> &rarr; {void}</span></h4>
    

    



<div class="description">
    <p>Attach the provider handling ad playback.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>provider</code></td>
            

            <td class="type">
            
                
<span class="param-type">Object</span>


            
            </td>

            

            

            <td class="description last"><p>The provider that will accept media commands and trigger media events.</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>













<h5>Returns:</h5>

        


<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">void</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="destroy"><span class="type-signature"></span>destroy<span class="signature">()</span><span class="type-signature"> &rarr; {void}</span></h4>
    

    



<div class="description">
    <p>Destroy this instream instance, reattach media and resume playback.</p>
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>













<h5>Returns:</h5>

        


<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">void</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="enableAdsMode"><span class="type-signature"></span>enableAdsMode<span class="signature">(clickThroughUrl)</span><span class="type-signature"> &rarr; {<a href="InstreamAdapter.html">InstreamAdapter</a>}</span></h4>
    

    



<div class="description">
    <p>Put the player in SSAI ad mode. Detaches media listeners
to prevent player events from being triggered during a break.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>clickThroughUrl</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last"><p>Url to open on click while playing</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    <ul>
<li>chainable</li>
</ul>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="InstreamAdapter.html">InstreamAdapter</a></span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="getMediaElement"><span class="type-signature"></span>getMediaElement<span class="signature">()</span><span class="type-signature"> &rarr; {Element|undefined}</span></h4>
    

    



<div class="description">
    <p>Extracts the video tag in the foreground.</p>
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    <p>videoTag - the HTML <video> element in the foreground.</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Element</span>
|

<span class="param-type">undefined</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="getState"><span class="type-signature"></span>getState<span class="signature">()</span><span class="type-signature"> &rarr; {string|boolean}</span></h4>
    

    



<div class="description">
    <p>Get the ad playback state. Returns false if destroyed.</p>
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    <p>The ad player's playback state</p>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">string</span>
|

<span class="param-type">boolean</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="hide"><span class="type-signature"></span>hide<span class="signature">()</span><span class="type-signature"> &rarr; {void}</span></h4>
    

    



<div class="description">
    <p>Hide the ads mode controls</p>
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>













<h5>Returns:</h5>

        


<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">void</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="init"><span class="type-signature"></span>init<span class="signature">()</span><span class="type-signature"> &rarr; {<a href="InstreamAdapter.html">InstreamAdapter</a>}</span></h4>
    

    



<div class="description">
    <p>Put the player in instream ads mode, detaching media, and preparing the ad program for
instream playback</p>
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    <ul>
<li>chainable</li>
</ul>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="InstreamAdapter.html">InstreamAdapter</a></span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="loadItem"><span class="type-signature"></span>loadItem<span class="signature">(item, options)</span><span class="type-signature"> &rarr; {Promise}</span></h4>
    

    



<div class="description">
    <p>Load an Item, playing it as an insteam ad.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>item</code></td>
            

            <td class="type">
            
                
<span class="param-type">Item</span>
|

<span class="param-type">Array.&lt;Item></span>


            
            </td>

            

            

            <td class="description last"><p>The ad item or ad pod array of items to be played.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>options</code></td>
            

            <td class="type">
            
                
<span class="param-type">Object</span>
|

<span class="param-type">Array.&lt;Object></span>


            
            </td>

            

            

            <td class="description last"><p>The ad options or ad pod array of options.</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    <ul>
<li>The ad playback promise.</li>
</ul>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Promise</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="pause"><span class="type-signature"></span>pause<span class="signature">()</span><span class="type-signature"> &rarr; {void}</span></h4>
    

    



<div class="description">
    <p>Pause ad playback.</p>
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>













<h5>Returns:</h5>

        


<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">void</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="play"><span class="type-signature"></span>play<span class="signature">()</span><span class="type-signature"> &rarr; {void}</span></h4>
    

    



<div class="description">
    <p>Resume ad playback.</p>
</div>













<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>













<h5>Returns:</h5>

        


<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">void</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="replacePlaylistItem"><span class="type-signature"></span>replacePlaylistItem<span class="signature">(item)</span><span class="type-signature"> &rarr; {void}</span></h4>
    

    



<div class="description">
    <p>Replace the current playlist item, with a new source. Used with SSAI plugins.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>item</code></td>
            

            <td class="type">
            
                
<span class="param-type">Item</span>


            
            </td>

            

            

            <td class="description last"><p>The new playlist item.</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>













<h5>Returns:</h5>

        


<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">void</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="setSkipOffset"><span class="type-signature"></span>setSkipOffset<span class="signature">(skipOffset)</span><span class="type-signature"> &rarr; {void}</span></h4>
    

    



<div class="description">
    <p>Sets the internal skip offset used for preloading content. Does not setup the skip button.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>skipOffset</code></td>
            

            <td class="type">
            
                
<span class="param-type">Number</span>


            
            </td>

            

            

            <td class="description last"><p>The number of seconds from the start where the ad becomes skippable.</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>













<h5>Returns:</h5>

        


<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">void</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="setState"><span class="type-signature"></span>setState<span class="signature">(event)</span><span class="type-signature"> &rarr; {void}</span></h4>
    

    



<div class="description">
    <p>Update instream player state. If <code>event.newstate</code> is 'playing' trigger an 'adPlay' event.
If <code>event.newstate</code> is 'paused' trigger and 'adPause' event.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>event</code></td>
            

            <td class="type">
            
                
<span class="param-type">AdPlayEvent</span>
|

<span class="param-type">AdPauseEvent</span>


            
            </td>

            

            

            <td class="description last"><p>An ad event object containing relavant ad data.</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>













<h5>Returns:</h5>

        


<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">void</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="setText"><span class="type-signature"></span>setText<span class="signature">(text)</span><span class="type-signature"> &rarr; {<a href="InstreamAdapter.html">InstreamAdapter</a>}</span></h4>
    

    



<div class="description">
    <p>Update the ads mode controlbar message.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>text</code></td>
            

            <td class="type">
            
                
<span class="param-type">string</span>


            
            </td>

            

            

            <td class="description last"><p>The message to display in the controlbar.</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    <ul>
<li>chainable</li>
</ul>
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type"><a href="InstreamAdapter.html">InstreamAdapter</a></span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="setTime"><span class="type-signature"></span>setTime<span class="signature">(event)</span><span class="type-signature"> &rarr; {void}</span></h4>
    

    



<div class="description">
    <p>Update instream time and trigger 'adTime' event.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>event</code></td>
            

            <td class="type">
            
                
<span class="param-type">AdTimeEvent</span>


            
            </td>

            

            

            <td class="description last"><p>An ad event object containing relavant ad data.</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>













<h5>Returns:</h5>

        


<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">void</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="setupSkipButton"><span class="type-signature"></span>setupSkipButton<span class="signature">(skipoffset, options, customNext<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {void}</span></h4>
    

    



<div class="description">
    <p>Add a skip button.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        
        <th>Attributes</th>
        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>skipoffset</code></td>
            

            <td class="type">
            
                
<span class="param-type">Number</span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            

            <td class="description last"><p>The number of seconds from the start where the ad becomes skippable.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>options</code></td>
            

            <td class="type">
            
                
<span class="param-type">Object</span>


            
            </td>

            
                <td class="attributes">
                

                

                
                </td>
            

            

            <td class="description last"><p>Custom skip button text and message.</p></td>
        </tr>

    

        <tr>
            
                <td class="name"><code>customNext</code></td>
            

            <td class="type">
            
                
<span class="param-type">function</span>


            
            </td>

            
                <td class="attributes">
                
                    &lt;optional><br>
                

                

                
                </td>
            

            

            <td class="description last"><p>The skip callback.</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>













<h5>Returns:</h5>

        


<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">void</span>


    </dd>
</dl>

    





        
            

    

    
    <h4 class="name" id="skipAd"><span class="type-signature"></span>skipAd<span class="signature">(event)</span><span class="type-signature"> &rarr; {void}</span></h4>
    

    



<div class="description">
    <p>Skip the current Ad.</p>
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>event</code></td>
            

            <td class="type">
            
                
<span class="param-type">Object</span>


            
            </td>

            

            

            <td class="description last"><p>The 'adSkipped' event object.</p></td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    

    
</dl>













<h5>Returns:</h5>

        


<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">void</span>


    </dd>
</dl>

    





        
    

    

    
</article>

</section>




</div>

<nav>
    <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Api.html">Api</a></li><li><a href="BackgroundMedia.html">BackgroundMedia</a></li><li><a href="InstreamAdapter.html">InstreamAdapter</a></li><li><a href="PlayerError.html">PlayerError</a></li><li><a href="Timer.html">Timer</a></li></ul><h3>Global</h3><ul><li><a href="global.html#ERROR_LOADING_PLAYLIST">ERROR_LOADING_PLAYLIST</a></li><li><a href="global.html#ERROR_LOADING_PLAYLIST_ITEM">ERROR_LOADING_PLAYLIST_ITEM</a></li><li><a href="global.html#ERROR_LOADING_PROVIDER">ERROR_LOADING_PROVIDER</a></li><li><a href="global.html#FLASH_ERROR">FLASH_ERROR</a></li><li><a href="global.html#FLASH_MEDIA_ERROR">FLASH_MEDIA_ERROR</a></li><li><a href="global.html#FLASH_SETUP_ERROR">FLASH_SETUP_ERROR</a></li><li><a href="global.html#HTML5_BASE_MEDIA_ERROR">HTML5_BASE_MEDIA_ERROR</a></li><li><a href="global.html#HTML5_ERROR_LIVE_STREAM_DOWN_OR_ENDED">HTML5_ERROR_LIVE_STREAM_DOWN_OR_ENDED</a></li><li><a href="global.html#HTML5_NETWORK_ERROR">HTML5_NETWORK_ERROR</a></li><li><a href="global.html#jwplayer">jwplayer</a></li><li><a href="global.html#load">load</a></li><li><a href="global.html#SETUP_ERROR_LICENSE_EXPIRED">SETUP_ERROR_LICENSE_EXPIRED</a></li><li><a href="global.html#SETUP_ERROR_LICENSE_INVALID">SETUP_ERROR_LICENSE_INVALID</a></li><li><a href="global.html#SETUP_ERROR_LICENSE_MISSING">SETUP_ERROR_LICENSE_MISSING</a></li><li><a href="global.html#SETUP_ERROR_LOADING_CORE_JS">SETUP_ERROR_LOADING_CORE_JS</a></li><li><a href="global.html#SETUP_ERROR_LOADING_PLAYLIST">SETUP_ERROR_LOADING_PLAYLIST</a></li><li><a href="global.html#SETUP_ERROR_LOADING_PROVIDER">SETUP_ERROR_LOADING_PROVIDER</a></li><li><a href="global.html#SETUP_ERROR_TIMEOUT">SETUP_ERROR_TIMEOUT</a></li><li><a href="global.html#SETUP_ERROR_UNKNOWN">SETUP_ERROR_UNKNOWN</a></li></ul>
</nav>

<br class="clear">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>
</footer>

<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>